import { getCurrentInstance, defineComponent, ComponentInternalInstance } from "vue";
export default defineComponent({
	props: {
		modelValue: Boolean
	},
	emits: ["submit", "update:modelValue"],
	setup(props, { emit }) {
		const { proxy } = getCurrentInstance() as ComponentInternalInstance;
		const change = (flag: boolean) => {
			emit("update:modelValue", flag);
		};
		const submit = () => {
			change(false);
			emit("submit");
		};
		return () => {
			return (
				<>
					<div>
						{props.modelValue ? null : (
							<el-button class="iconfont iconedit ml-2" type="primary" onClick={() => change(true)}>
								{proxy?.$t("frame.btn.edit")}
							</el-button>
						)}
						{props.modelValue ? (
							<>
								<el-button class="iconfont iconbx-x ml-2" onClick={() => change(false)}>
									{proxy?.$t("frame.btn.cancel")}
								</el-button>
								<el-button class="iconfont iconsave ml-2" type="primary" onClick={() => submit()}>
									{proxy?.$t("frame.btn.save")}
								</el-button>
							</>
						) : null}
					</div>
				</>
			);
		};
	}
});
